def get_homo(kpA,kpB,matches):
    reprojThresh=4.0
    kpsA=np.float32([kp.pt for kp in kpA])
    kpsB=np.float32([kp.pt for kp in kpB])
    ptsA=np.float32([kpsA[m[0].queryIdx]for m in matches])
    (H,status)=cv2.findHomography(ptsB,pts,cv2.RANSAC,reporjThresh)
    return H
if len(matches)>4
    H=get_homo(kpA,kpB,matches)
    result=cv2.warpPerspective(img2,H,(img1.shape[1]+img2.shape[1],img2.shape[0]))
    cv2.imshow('RIght',result)
    result[0:img1.shape[0],0:img1.shape[1]]=img1
    cv2.imshow('Result',result)
    cv2.waitKey()
    cv2.destroyALLWindows()